package cn.virens.web.components.shiro.oauth2;

import cn.virens.oauth2.Oauth2Client;
import cn.virens.oauth2.standard.Oauth2AccessTokenResponse;
import cn.virens.util.Assert;

public abstract class PrincipalGetter {
	protected Oauth2Client oauth2Client;

	public Oauth2Client getOauth2Client() {
		return oauth2Client;
	}

	public void setOauth2Client(Oauth2Client oauth2Client) {
		this.oauth2Client = oauth2Client;
	}

	public Object getPrincipal(Oauth2AccessTokenResponse respone) {
		return Assert.isEmpty(get(respone), "Principal is empty!");
	}

	protected abstract Object get(Oauth2AccessTokenResponse respone);
}
